﻿using System.Runtime.Serialization;
using System.Collections.ObjectModel;
using SmartMD.DataModel;
using System;

namespace SmartMD.DataModel.Entity
{
    [DataContract(Name = "SysDicType", Namespace = "")]
    public class DictionaryType : BusinessEntity
    {

        private string code;
        /// <summary>
        /// 字典类别CODE
        /// </summary>
        [DataMember(Name = "ename", EmitDefaultValue = false)]
        public string Code
        {
            get { return code; }
            set
            {
                if (code != value)
                {
                    code = value;
                    OnPropertyChanged("Code");
                }
            }
        }

        private string name;
        /// <summary>
        /// 字典类别名称
        /// </summary>
        [DataMember(Name = "cname", EmitDefaultValue = false)]
        public string Name
        {
            get { return name; }
            set
            {
                if (name != value)
                {
                    name = value;
                    OnPropertyChanged("Name");
                }
            }
        }

        private string description;
        /// <summary>
        /// 字典类别描述
        /// </summary>
        [DataMember(Name = "description", EmitDefaultValue = false)]
        public string Description
        {
            get { return description; }
            set
            {
                if (description != value)
                {
                    description = value;
                    OnPropertyChanged("Description");
                }
            }
        }

        private string groupinfo;
        /// <summary>
        /// 字典分组信息
        /// </summary>
        [DataMember(Name = "groupinfo", EmitDefaultValue = false)]
        public string Groupinfo
        {
            get { return groupinfo; }
            set
            {
                if (groupinfo != value)
                {
                    groupinfo = value;
                    OnPropertyChanged("Groupinfo");
                }
            }
        }

        private ObservableCollection<DictionaryItem> items;
        /// <summary>
        /// 字典类别包含的字典项列表
        /// </summary>
        [DataMember(Name = "sysdicitems", EmitDefaultValue = false)]
        public ObservableCollection<DictionaryItem> Items
        {
            get
            {
                if (items == null)
                {
                    items = new ObservableCollection<DictionaryItem>();
                }
                return items;
            }
            set
            {
                items = value;
                OnPropertyChanged("Items");
            }
        }

        public override void setValue(string key, Object value)
        {
            if (value is System.DBNull)
                return;
            switch (key.ToLower())
            {
                case "dictypeid":
                    this.Id = (string)value;
                    break;
                case "cname":
                    this.Name = (string)value;
                    break;
                case "ename":
                    this.Code = (string)value;
                    break;
                case "description":
                    this.Description = (string)value;
                    break;
                case "groupinfo":
                    this.Groupinfo = (string)value;
                    break;
                default:
                    break;
            }
        }
    }
}
